package net.lab1024.sa.admin.module.business.erp.service;

import java.util.List;
import net.lab1024.sa.admin.module.business.erp.dao.TmsordDao;
import net.lab1024.sa.admin.module.business.erp.domain.entity.TmsordEntity;
import net.lab1024.sa.admin.module.business.erp.domain.form.add.TmsordAddForm;

import net.lab1024.sa.admin.module.business.erp.domain.form.query.TmsordQueryForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.update.TmsordUpdateForm;
import net.lab1024.sa.admin.module.business.erp.domain.vo.TmsordVO;
import net.lab1024.sa.admin.util.AdminSqlserverDao;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * BOM表 Service
 *
 * @Author AKITA
 * @Date 2025-08-15 10:54:43
 * @Copyright AKITA
 */

@Service
public class TmsordService {

    @Resource
    private TmsordDao tmsordDao;

    /**
     * 分页查询
     */
    public PageResult<TmsordVO> queryPage(TmsordQueryForm queryForm) {
        Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
        List<TmsordVO> list = AdminSqlserverDao.queryPage(page, queryForm);
        return SmartPageUtil.convert2PageResult(page, list);
    }

    /**
     * 添加
     */
    public ResponseDTO<String> add(TmsordAddForm addForm) {
        TmsordEntity tmsordEntity = SmartBeanUtil.copy(addForm, TmsordEntity.class);
        AdminSqlserverDao.insert(tmsordEntity);
        return ResponseDTO.ok();
    }

    /**
     * 更新
     *
     */
    public ResponseDTO<String> update(TmsordUpdateForm updateForm) {
        TmsordEntity tmsordEntity = SmartBeanUtil.copy(updateForm, TmsordEntity.class);
        tmsordDao.updateById(tmsordEntity);
        return ResponseDTO.ok();
    }

    /**
     * 批量删除
     */
    public ResponseDTO<String> batchDelete(List<Long> idList) {
        tmsordDao.deleteBatchIds(idList);
        return ResponseDTO.ok();
    }

    /**
     * 单个删除
     */
    public ResponseDTO<String> delete(Long id) {
        AdminSqlserverDao.deleteById(id);
        return ResponseDTO.ok();
    }

    public List<TmsordVO> getList(TmsordQueryForm queryForm) {
       return AdminSqlserverDao.getList(queryForm);
    }
}
